import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AnnualPlanForm, AnnualPlanQuery, AnnualPlanVO } from '@/api/iot/annualPlan/types';

/**
 * 查询电梯年检计划列表
 * @param query
 * @returns {*}
 */

export const listAnnualPlan = (query?: AnnualPlanQuery): AxiosPromise<AnnualPlanVO[]> => {
  return request({
    url: '/iot/annualPlan/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询电梯年检计划详细
 * @param planId
 */
export const getAnnualPlan = (planId: string | number): AxiosPromise<AnnualPlanVO> => {
  return request({
    url: '/iot/annualPlan/' + planId,
    method: 'get'
  });
};

/**
 * 新增电梯年检计划
 * @param data
 */
export const addAnnualPlan = (data: AnnualPlanForm) => {
  return request({
    url: '/iot/annualPlan',
    method: 'post',
    data: data
  });
};

/**
 * 修改电梯年检计划
 * @param data
 */
export const updateAnnualPlan = (data: AnnualPlanForm) => {
  return request({
    url: '/iot/annualPlan',
    method: 'put',
    data: data
  });
};

/**
 * 删除电梯年检计划
 * @param planId
 */
export const delAnnualPlan = (planId: string | number | Array<string | number>) => {
  return request({
    url: '/iot/annualPlan/' + planId,
    method: 'delete'
  });
};

/**
 * 生成电梯年检计划
 */
export const generateAnnualPlan = () => {
  return request({
    url: '/iot/annualPlan/generate',
    method: 'post'
  });
};
